package com.springDemo.Hibernate.dao;

import com.springDemo.Hibernate.entity.AddressBook;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * Created by Administrator on 2016/8/10.
 */
public class AddressBookDaoImpl extends HibernateDaoSupport implements IAddressBookDao {

    @Override
    public int countAll() {
        String  countAllSql = "select count(*) from AddressBook";
        Number count = 0;
        count = (Number) getHibernateTemplate().find(countAllSql).get(0);
        return count.intValue();
    }

    @Override
    public void save(AddressBook addressBook) {
       getHibernateTemplate().save(addressBook);
    }

}
